import unittest
import requests

# 发送post json 方式传参
class MyTestCase(unittest.TestCase):
    def test_something(self):
        # head={"Content-Type":"application/json"}
        # url可以加headers 发送请求类型(headers可以不加)
        kdata = {"userName":"student","password":"123456","remember":False}
        k = requests.post("http://101.200.61.210:8081/api/user/login",json=kdata,timeout=2)
        if k.status_code == 200:
            ks = k.json()
            print(ks)
            username = ks['response']['userName'] # 获取用户的登录名
            self.assertEqual(username, "student") # 断言
            print(k.json())
            print(k.cookies)
        else:
            pass


if __name__ == '__main__':
    unittest.main()
